package com.xu.ai.model.dashscopeopenaiadapter.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * ChatClient聊天客户端 controller
 *
 * @author xuguan
 * @since 2025/11/3
 */
@RestController
@RequestMapping("/api/dashscope-openai-adapter/chat")
public class ChatController {
	private final ChatClient chatClient;

	public ChatController(ChatClient.Builder chatClientBuilder) {
		this.chatClient = chatClientBuilder.build();
	}

	@GetMapping("/call")
	public Flux<String> call() {
		return chatClient.prompt("你是谁?").stream().content();
	}
}
